<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html>
<script src="//unpkg.com/crypto-js/crypto-js.js"></script>
<script>
    function getAesString(data,key,iv){//加密
        var key  = CryptoJS.enc.Utf8.parse(key);
        //alert(key）;
        var iv   = CryptoJS.enc.Utf8.parse(iv);
        var encrypted =CryptoJS.AES.encrypt(data,key,
            {
                iv:iv,
                mode:CryptoJS.mode.CBC,
                padding:CryptoJS.pad.Pkcs7
            });
        return encrypted.toString();    //返回的是base64格式的密文
    }
    function getDAesString(encrypted,key,iv){//解密
        var key  = CryptoJS.enc.Utf8.parse(key);
        var iv   = CryptoJS.enc.Utf8.parse(iv);
        var decrypted =CryptoJS.AES.decrypt(encrypted,key,
            {
                iv:iv,
                mode:CryptoJS.mode.CBC,
                padding:CryptoJS.pad.Pkcs7
            });
        return decrypted.toString(CryptoJS.enc.Utf8);      //
    }

    console.log(getAesString('1111','2222','3333'));
    console.log(getDAesString('7tWoLlYsuA4h2uPVFyAGOw==','2222','3333'));

</script>